package com.mailbox.mailbox.domain;

import cn.hutool.core.convert.Convert;
import lombok.AllArgsConstructor;
import lombok.Data;

import javax.websocket.Session;
import java.time.LocalDateTime;

/**
 * @author 张铭辉
 */
@Data
@AllArgsConstructor
public class OnlineUser extends Convert {
    /**
     * 用户ID
     */
    private Integer userId;
    /**
     * 用户会话 (使用该对象进行消息发送)
     */
    private Session session;
    /**
     * 连接时间
     */
    private String createTime;

    /**
     * @param userId   用户id
     * @param session  用户session 回话信息
     */
    public OnlineUser(Integer userId, Session session) {
        this.userId = userId;
        this.session = session;
        LocalDateTime localDateTime=LocalDateTime.now();
        this.createTime = String.valueOf(localDateTime);
    }
}